# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=libabigail
pkgver=2.3
pkgrel=0
pkgdesc="The ABI Generic Analysis and Instrumentation Library"
url="https://sourceware.org/libabigail/"
arch="all"
license="Apache-2.0 WITH LLVM-exception"
makedepends="
	autoconf
	automake
	elfutils-dev
	libtool
	libxml2-dev
	musl-fts-dev
	py3-sphinx
	"
checkdepends="
	bash
	python3
	"
subpackages="
	$pkgname-dev
	$pkgname-tools
	$pkgname-doc
	$pkgname-bash-completion
	"
source="https://mirrors.kernel.org/sourceware/libabigail/libabigail-$pkgver.tar.xz
	musl-fts.patch
	apk.patch
	"

prepare() {
	default_prepare

	autoreconf -fi
}

build() {
	# utilities use a bit more stack size than normal
	export LDFLAGS="$LDFLAGS -Wl,-z,stack-size=512000"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--enable-rpm=no \
		--enable-rpm415=no \
		--enable-debug-self-comparison=no \
		--enable-deb=no \
		--enable-tar=yes \
		--enable-apidoc=no \
		--enable-manual=yes \
		--enable-bash-completion=yes \
		--enable-fedabipkgdiff=no \
		--enable-python3=yes
	make
	make -C doc/manuals man
}

check() {
	make check check-self-compare || {
		cat tests/test-suite.log
		return 1
	}
}

package() {
	make DESTDIR="$pkgdir" install
	make -C doc/manuals DESTDIR="$pkgdir" install-man-and-info-doc

	cd bash-completion
	install -D -m644 -t "$pkgdir"/usr/share/bash-completion/completions/ \
		abicompat \
		abidiff \
		abidw \
		abilint \
		abipkgdiff

}

tools() {
	pkgdesc="$pkgdesc (CLI tools)"
	depends="$pkgname=$pkgver-r$pkgrel"

	amove usr/bin
}

sha512sums="
fdf0df51e2c262c723c11bef58cd0b89b27e67be196edeb33444fc06e7e61d3c2c227f59cb961aea6fc0c9b7f6f04e08b787a1cbbeb3d5507b968b8ae7630527  libabigail-2.3.tar.xz
d789a76dfedf9e74c13906aa72da4f9f4113484a98326f662ed9a2badbd29d7fb5e402272bfe24dbdfaf44992ba6a9be3d8ecbdda275910e00cf4f0abaac96e2  musl-fts.patch
78bdbb2fd285b5dd2ceaac8a3631e433d4f154b6882c09be7117ef4ead35f872a19b33ca21e1c8d738baa78e3784aebd2d25c731b50a8c3c3c47d616dc33b5fd  apk.patch
"
